package com.tanger.pay.alipay;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.PropertySource;

import javax.annotation.PostConstruct;

/**
 * @Description 支付宝配置
 * @Author Hchenbin
 * @Date 2024-01-02 17:38
 * @Version 1.0
 */
@ConfigurationProperties(prefix = "alipay")
@EnableConfigurationProperties(AliPayConfig.class)//标注为配置类
@PropertySource(value = {"classpath:AliPayConfig.properties"})
public class AliPayConfig1 {

    @Value("${appId}")
    private String _appId;
    @Value("${appPrivateKey}")
    private String _appPrivateKey;
    @Value("${alipayPublicKey}")
    private String _alipayPublicKey;
//    @Value("${notifyUrl}")
//    private String _notifyUrl;
    @Value("${gatewayUrl}")
    private String _gatewayUrl;
    //证书路径
    @Value("${app_cert_path}")
    private String app_cert_path;
    @Value("${alipay_cert_path}")
    private String alipay_cert_path;
    @Value("${alipay_root_cert_path}")
    private String alipay_root_cert_path;

    public static String appId;
    /**
     * 私钥
     */
    public static String appPrivateKey;
    /**
     * 公钥
     */
    public static String alipayPublicKey;
    /**
     * 回调地址
     */
//    public static String notifyUrl;
    /**
     * 沙箱网关
     */
    public static String gatewayUrl;
    /**
     * 应用公钥证书路径
     */
    public static String appCertPath;
    /**
     * 支付宝公钥证书路径
     */
    public static String alipayCertPath;
    /**
     * 支付宝根证书路径
     */
    public static String alipayRootCertPath;

    @PostConstruct
    public void init() {
        appId = _appId;
        appPrivateKey = _appPrivateKey;
        alipayPublicKey = _alipayPublicKey;
//        notifyUrl = _notifyUrl;
        gatewayUrl = _gatewayUrl;

        appCertPath = app_cert_path;
        alipayCertPath = alipay_cert_path;
        alipayRootCertPath = alipay_root_cert_path;
    }
}
